package edu.hunau.cxb19.oop.class04.oop;

/**
 * 平面中的圆
 * 
 * @author hb
 *
 *         2020-02-26 16:15:20
 */
public class Circle extends Shape {
	/**
	 * 描述圆的半径
	 */
	private int r;

	public Circle() {

	}

	@Override
	public double area() {
		return r * r * Math.PI;
	}

	public Circle(Point location, int r) {
		// super.setLocation(location);
		super(location);
		this.r = r;
	}

	/**
	 * @return the r
	 */
	public int getR() {
		return r;
	}

	/**
	 * @param r the r to set
	 */
	public void setR(int r) {
		this.r = r;

	}
 
	/**
	 * 判定一个点是否在圆的内部
	 */
	public boolean contains(Point p) {
		//获得点到圆心的距离
		return this.getLocation().distance(p)<=this.r;
	}

}
